home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / ZTIMER11.ARJ / LZTEST.ASM < prev    next >
Assembly Source File  |  1992-04-21  |  3KB  |  107 lines

  1. ;****************************************************************************
  2. ;*
  3. ;*                           Long Period Zen Timer
  4. ;*
  5. ;*                               From the book
  6. ;*                         "Zen of Assembly Language"
  7. ;*                            Volume 1, Knowledge
  8. ;*
  9. ;*                             by Michael Abrash
  10. ;*
  11. ;*                      Modifications by Kendall Bennett
  12. ;*
  13. ;* Filename:    $RCSfile: lztest.asm $
  14. ;* Version:        $Revision: 1.2 $
  15. ;*
  16. ;* Language:    8086 Assembler
  17. ;* Environment:    IBM PC (MS DOS)
  18. ;*
  19. ;* Description:    Standalone .exe program to measure the performance of code
  20. ;*                that takes more than 54 ms to execute.
  21. ;*
  22. ;*                Link with LZTIMER.ASM. LZTEST.BAT can be used to assemble,
  23. ;*                link and run the test. Code to be measured must be in the
  24. ;*                file TESTCODE. See DLYTST.ASM for example test code.
  25. ;*
  26. ;* $Id: lztest.asm 1.2 92/01/27 21:38:23 kjb release $
  27. ;*
  28. ;* Revision History:
  29. ;* -----------------
  30. ;*
  31. ;* $Log:    lztest.asm $
  32. ;* Revision 1.2  92/01/27  21:38:23  kjb
  33. ;* First release to the public.
  34. ;* 
  35. ;* Revision 1.1  91/11/14  17:16:07  kjb
  36. ;* Initial revision
  37. ;* 
  38. ;****************************************************************************
  39.  
  40.         IDEAL
  41.  
  42. INCLUDE "model.mac"                ; Memory model macros
  43.  
  44. segment    mystack para stack 'STACK'
  45.         db        512 dup(?)
  46. ends    mystack
  47.  
  48. header        lztest                ; Set up memory model
  49.  
  50. begcodeseg    lztest                ; Start of code segment
  51.  
  52.         assume ds:_TEXT            ; Access data in the code segment
  53.  
  54.         extrn _LZTimerOn:far, _LZTimerOff:far, _LZTimerReport:far
  55.  
  56. ; Set up a few equates to map calls to ZTimerOn, ZTimerOff and ZTimerReport
  57. ; to the 'C' callable long period timing routines.
  58.  
  59. ZTimerOn        EQU    _LZTimerOn
  60. ZTimerOff        EQU    _LZTimerOff
  61. ZTimerReport    EQU    _LZTimerReport
  62.  
  63. proc    Start    near
  64.  
  65.         push    cs
  66.         pop        ds                ; Set ds to point to the code segment,
  67.                                 ; so data as well as code can easily
  68.                                 ; be included in TESTCODE
  69.  
  70. ; Delay for 1-2 seconds, to let the Enter keystroke that started the
  71. ; program to come back up (the upstroke).
  72.  
  73.         mov        ah,2ch
  74.         int        21h                ; Get current time
  75.         mov        bh,dh            ; set the current time aside
  76. @@DelayLoop:
  77.         mov        ah,2ch
  78.         push    bx                ; preserve start time
  79.         int        21h                ; get time
  80.         pop        bx                ; retrieve start time
  81.         cmp        dh,bh            ; Is the new seconds count less than the
  82.                                 ;  start seconds count?
  83.         jnb        @@CheckDelayTime ; no
  84.         add        ah,60            ; yes, a minute must have turned over, so
  85.                                 ;  add one minute.
  86. @@CheckDelayTime:
  87.         sub        dh,bh            ; Get time that's passed
  88.         cmp        dh,2            ; has it been more than 2 seconds yet?
  89.         jb        @@DelayLoop        ; not yet
  90.  
  91. INCLUDE    "testcode"
  92.  
  93. ; Display the results
  94.  
  95.         call    _LZTimerReport
  96.  
  97. ; Terminate the program
  98.  
  99.         mov        ah,4ch
  100.         int        21h
  101.  
  102. endp    Start
  103.  
  104. endcodeseg    lztest
  105.  
  106.         END        Start            ; End of module
  107.